# 79 数据容器的通用操作
# my_list = [1, 2, 3, 4, 5]
# my_tuple = (1, 2, 3, 4, 5)
# my_str = 'abcdefg'
# my_set = {1, 2, 3, 4, 5}
# my_dict = {"key1": 1, "key2": 2, "key3": 3, "key4": 4, "key5": 5}
#
# print(f"列表 元素个数有：{len(my_list)}")
# print(f"元组 元素个数有：{len(my_tuple)}")
# print(f"字符串 元素个数有：{len(my_str)}")
# print(f"集合 元素个数有：{len(my_set)}")
# print(f"字典 元素个数有：{len(my_dict)}")
#
# # max最大元素
# print(f"列表 元素个数有：{max(my_list)}")
# print(f"元组 元素个数有：{max(my_tuple)}")
# print(f"字符串 元素个数有：{max(my_str)}")
# print(f"集合 元素个数有：{max(my_set)}")
# print(f"字典 元素个数有：{max(my_dict)}")
#
# # min最小元素
# print(f"列表 元素个数有：{min(my_list)}")
# print(f"元组 元素个数有：{min(my_tuple)}")
# print(f"字符串 元素个数有：{min(my_str)}")
# print(f"集合 元素个数有：{min(my_set)}")
# print(f"字典 元素个数有：{min(my_dict)}")
#
# # 类型转换：容器转列表
# print(f"列表转列表的结果是：{list(my_list)}")
# print(f"元组转列表的结果是：{list(my_tuple)}")
# print(f"字符串转列表的结果是：{list(my_str)}")
# print(f"集合转列表的结果是：{list(my_set)}")
# print(f"字典转列表的结果是：{list(my_dict)}")
#
# # 类型转换：容器转元组
# print(f"列表转元组的结果是：{tuple(my_list)}")
# print(f"元组转元组的结果是：{tuple(my_tuple)}")
# print(f"字符串转列元组的结果是：{tuple(my_str)}")
# print(f"集合转元组的结果是：{tuple(my_set)}")
# print(f"字典转元组的结果是：{tuple(my_dict)}")
#
# # 类型转换：容器转字符串
# print(f"列表转字符串的结果是：{str(my_list)}")
# print(f"元组转字符串的结果是：{str(my_tuple)}")
# print(f"字符串转列字符串的结果是：{str(my_str)}")
# print(f"集合转字符串的结果是：{str(my_set)}")
# print(f"字典转字符串的结果是：{str(my_dict)}")
#
# # 类型转换：容器转集合
# print(f"列表转字符串的结果是：{set(my_list)}")
# print(f"元组转字符串的结果是：{set(my_tuple)}")
# print(f"字符串转列字符串的结果是：{set(my_str)}")
# print(f"集合转字符串的结果是：{set(my_set)}")
# print(f"字典转字符串的结果是：{set(my_dict)}")
#
# # 容器排序
# my_list = [3, 1, 2, 5, 4]
# my_tuple = (3, 1, 2, 5, 4)
# my_str = "bdcefga"
# my_set = {3, 1, 2, 5, 4}
# my_dict = {"key3": 1, "key1": 2, "key2": 3, "key5": 4, "key4": 5}
#
# print(f"列表对象的排序结果：{sorted(my_list)}")
# print(f"元组对象的排序结果：{sorted(my_tuple)}")
# print(f"字符串对象的排序结果：{sorted(my_str)}")
# print(f"集合对象的排序结果：{sorted(my_set)}")
# print(f"字典对象的排序结果：{sorted(my_dict)}")
#
# print(f"列表对象的反向排序结果：{sorted(my_list, reverse=True)}")
# print(f"元组对象的反向排序结果：{sorted(my_tuple, reverse=True)}")
# print(f"字符串对象反向的排序结果：{sorted(my_str, reverse=True)}")
# print(f"集合对象的反向排序结果：{sorted(my_set, reverse=True)}")
# print(f"字典对象的反向排序结果：{sorted(my_dict, reverse=True)}")

# 80 字符串大小比较
# print(f"abd大于abc，结果{'abd' > 'abc'}")
# print(f"ab大于a，结果：{'ab' > 'a'}")
# print(f"a大于A，结果：{'a' > 'A'}")
# print(f"key1大于key2，结果：{'key1' > 'key2'}")

# 81 函数的多返回值
# def first_test_return():
#     return 1, 2, 3
#
#
# x, y, z = first_test_return()
# print(x)
# print(y)
# print(z)

# 81 函数的多种参数使用形式
# def user_info(name, age, gender):
#     print(f"姓名是：{name}，年龄是：{age}，性别是：{gender}")
#
#
# user_info('wenxiaojian', 20, '男')
#
# # 关键字参数
# user_info(name='hanlei', age=25, gender='女')
# user_info(age=18, gender='女', name='wenjie')
# user_info('李书逸', gender='男', age=1)
#
#
# # 缺省参数（默认值）
# def user_info(name, age, gender):
#     print(f"姓名是：{name}，年龄是：{age}，性别是：{gender}")
#
#
# user_info('wenxiaojian', 20, '男')
#
#
# def user_info(*args):
#     print(f"args参数的类型是：{type(args)}，内容是：{args}")
#
#
# user_info(1, 2, 3, 'xiaoming', 'nanhai')
#
#
# def user_info(**kwargs):
#     print(f"args参数的类型是：{type(kwargs)}，内容是:{kwargs}")
#
#
# user_info(name='小王', age=11, gender='男孩')

# 83 函数作为参数传递
# def first_test_func(computer):
#     result = computer(1, 2)
#     print(f"computer参数的类型是：{type(computer)}")
#     print(f"计算结果：{result}")
#
#
# def computer(x, y):
#     return x + y
#
#
# first_test_func(computer)

# 84 lambda 匿名函数

# def first_info_func(computer):
#     result = computer(1, 2)
#     print(f"computer参数的类型是：{type(computer)}")
#     print(f"计算结果：{result}")
#
#
# first_info_func(lambda x, y: x + y)

# 85 文件编码的概念
# f = open("E:/Desktop/test.txt", "r", encoding="UTF-8")
# print(type(f))

# 读取文件
# print(f"读取十个字节的结果：{f.read(10)}")
# print(f"read方法读取全部内容的结果是：{f.read()}")

# 读取文件--readlines
# lines = f.readlines()
# print(lines)
# print(type(lines))

# 读取文件--readline(一行一行的读取)
# line1 = f.readline()
# line2 = f.readline()
# line3 = f.readline()
# print(line1)
# print(line2)
# print(line3)

# for循环读取文件行
# for line in f:
#     print(f"每一行的数据是：{line}")
#
# f.close()  #关闭文件

# with open("E:/Desktop/test.txt", "r", encoding="UTF-8") as f:
#     for line in f:
#         print(line, end='')

# 87 练习
# f = open('E:/Desktop/test1.txt', 'r', encoding='UTF-8')
# lines = f.read()
# print(lines, )
# count = lines.count('itheima')
# print(count)
# f.close()
# count = 0
# for line in f:
#     print(line)
#     words = line.split()
#     for word in words:
#         if word == 'itheima':
#             count += 1
# print(count)
# f.close()

# 88 文件的写入
# f = open('E:/Desktop/test2.txt', 'w', encoding='UTF-8') #没有的话就是写入
# f.write('wenxiaojian')
# f.flush()
# f.close()

# f = open('E:/Desktop/test2.txt', 'w', encoding='UTF-8')
# f.write('wenjiehanlei')
# f.close()
